<?php
require '../config/auth.php';
header('Content-Type: text/html; charset=utf-8');

require_once('../config/config.inc');
//Connect to mysql server
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link) {
	die('Failed to connect to server: ' . mysql_error());
}

//Select database
$db = mysql_select_db(DB_DATABASE);
if(!$db) {
	die("Unable to select database");
}

mysql_set_charset('utf8',$db);
mysql_query("SET CHARACTER SET utf8");
mysql_query("SET NAMES utf8_persian_ci");
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta content="text/html;charset=UTF-8" http-equiv="Content-Type" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">

<title>BookStore - Admin</title>

<!-- Bootstrap core CSS -->
<link href="../assets/css/bootstrap.css" rel="stylesheet">
<link href="../assets/css/fonts.css" rel="stylesheet">
<link href="../assets/css/fonts.min.css" rel="stylesheet">

<!-- Add custom CSS here -->
<link href="../assets/css/small-business.css" rel="stylesheet">

</head>

<body>

	<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
		<div class="container">
			<div class="navbar-header pull-right">
				<button type="button" class="navbar-toggle" data-toggle="collapse"
					data-target=".navbar-ex1-collapse">
					<span class="sr-only">Toggle navigation</span> <span
						class="icon-bar"></span> <span class="icon-bar"></span> <span
						class="icon-bar"></span>
				</button>
				<!-- You'll want to use a responsive image option so this logo looks good on devices - I recommend using something like retina.js (do a quick Google search for it and you'll find it) -->
				<a class="navbar-brand logo-nav" href="index.html"><img
					src="../assets/img/logo.jpg" style="height: 75px; width: 150px;"></a>
			</div>

			<!-- Collect the nav links, forms, and other content for toggling -->
			<div class="collapse navbar-collapse navbar-ex1-collapse pull-left">
				<ul class="nav navbar-nav navbar-right">
					<li><a href="../index.html">صفحه اصلی</a></li>
				</ul>
			</div>
			<!-- /.navbar-collapse -->
		</div>
		<!-- /.container -->
	</nav>

	<div class="container">
		<div class="panel-group" id="accordion">
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion"
							href="#collapseOne"> کتاب ها </a>
					</h4>
				</div>
				<div id="collapseOne" class="panel-collapse collapse in">
					<div class="panel-body">
						<div class="row">
							<div class="col-lg-6">
								<div class="well">
									<h2>لست کتب</h2>
									<table class="table">
									<tr style="background: gray;"><td>#</td><td>اسم</td><td>حذف</td></tr>
									<?php 
										$qry1=mysql_query("SELECT * FROM `books`");
										if(!$qry1){ echo "VERY BADDDDDD"; }
										$count1=1;
										while($rowbook2=mysql_fetch_array($qry1)){
									?>
									<tr><td><?php echo $count1; ?></td><td><?php echo $rowbook2['name']; ?></td><td><a href="execute/b_del.php?id=<?php echo $rowbook2['id']; ?>">حذف</a></td></tr>
									<?php } ?>
									</table>
								</div>
							</div>
							<div class="col-lg-6">
								<div class="well">
									<h2>اضافه کتاب جدید</h2>
									<form role="form" action="execute/add_book.php" method="post" enctype="multipart/form-data">
										<div class="form-group">
											<label for="exampleInputEmail1">اسم کتاب</label> <input
												type="text" class="form-control" name="bookName"
												placeholder="اسم" required>
										</div>
										<div class="form-group">
											<label for="exampleInputEmail1">مولف</label>
											<select class="form-control" name="bookAuthor">
												<?php 
												$qrybook = mysql_query("SELECT * FROM `scholars` order by name");
												while($rowbook=mysql_fetch_array($qrybook)){
												?>
												<option value="<?php echo $rowbook['id']; ?>"><?php echo $rowbook['name']; ?></option>
												<?php } ?>
											</select>
										</div>
										<div class="form-group">
											<label for="exampleInputPassword1"> توضیحات</label>
											<textarea class="form-control" name="bookDesc" rows="5"></textarea>
										</div>
										<div class="form-group">
											<label for="exampleInputFile">فایل کتاب</label> <input
												type="file" name="bookFile" id="exampleInputFile" required>
											<p class="help-block"></p>
										</div>
										<div class="form-group">
											<label for="exampleInputFile">تصویر</label>
											 <input
												type="file" name="bookImg" id="exampleInputFile" required>
											<p class="help-block"></p>
										</div>
										
										<button type="submit" class="btn btn-primary">تایید و اضافه</button>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion"
							href="#collapseTwo"> کلیپ های صوتی </a>
					</h4>
				</div>
				<div id="collapseTwo" class="panel-collapse collapse">
					<div class="panel-body">
					<div class="row">
							<div class="col-lg-6">
								<div class="well">
									<h2>لست کلیپ های صوتی</h2>
									<table class="table">
									<tr style="background: gray;"><td>#</td><td>اسم</td><td>حذف</td></tr>
									<?php 
										$qryaudio=mysql_query("SELECT * FROM `audio`");
										if(!$qryaudio){ echo "VERY BADDDDDD"; }
										$count1=1;
										while($rowaudio=mysql_fetch_array($qryaudio)){
									?>
									<tr><td><?php echo $count1; ?></td><td><?php echo $rowaudio['name']; ?></td><td><a href="execute/audio_del.php?id=<?php echo $rowaudio['id']; ?>">حذف</a></td></tr>
									<?php } ?>
									</table>
								</div>
							</div>
							<div class="col-lg-6">
								<div class="well">
									<h2>اضافه کلیپ صوتی</h2>
									<form role="form" action="execute/add_audio.php" method="post" enctype="multipart/form-data">
										<div class="form-group">
											<label for="exampleInputEmail1">موضوع</label> <input
												type="text" class="form-control" name="audioName"
												placeholder="اسم" required>
										</div>
										<div class="form-group">
											<label for="exampleInputEmail1">گوینده</label>
											<select class="form-control" name="audioSpeaker">
												<?php 
												$qrybook22 = mysql_query("SELECT * FROM `scholars` order by name");
												while($rowbook22=mysql_fetch_array($qrybook22)){
												?>
												<option value="<?php echo $rowbook22['id']; ?>"><?php echo $rowbook22['name']; ?></option>
												<?php } ?>
											</select>
										</div>
										<div class="form-group">
											<label for="exampleInputFile">فایل صوتی</label> <input
												type="file" name="audioFile" id="exampleInputFile" required>
											<p class="help-block"></p>
										</div>
										
										<button type="submit" class="btn btn-primary">تایید و اضافه</button>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion"
							href="#collapseThree"> کلیپ های تصویری </a>
					</h4>
				</div>
				<div id="collapseThree" class="panel-collapse collapse">
					<div class="panel-body">
					<div class="row">
							<div class="col-lg-6">
								<div class="well">
									<h2>لست کلیپ های تصویری</h2>
									<table class="table">
									<tr style="background: gray;"><td>#</td><td>اسم</td><td>حذف</td></tr>
									<?php 
										$qryvideo=mysql_query("SELECT * FROM `video`");
										if(!$qryvideo){ echo "VERY BADDDDDD"; }
										$count1=1;
										while($rowvideo=mysql_fetch_array($qryvideo)){
									?>
									<tr><td><?php echo $count1; ?></td><td><?php echo $rowvideo['name']; ?></td><td><a href="execute/video_del.php?id=<?php echo $rowvideo['id']; ?>">حذف</a></td></tr>
									<?php } ?>
									</table>
								</div>
							</div>
							<div class="col-lg-6">
								<div class="well">
									<h2>اضافه کلیپ تصویری</h2>
									<form role="form" action="execute/add_video.php" method="post" enctype="multipart/form-data">
										<div class="form-group">
											<label for="exampleInputEmail1">موضوع</label> <input
												type="text" class="form-control" name="videoName"
												placeholder="اسم" required>
										</div>
										<div class="form-group">
											<label for="exampleInputEmail1">گوینده</label>
											<select class="form-control" name="videoSpeaker">
												<?php 
												$qrybook33 = mysql_query("SELECT * FROM `scholars` order by name");
												while($rowbook33=mysql_fetch_array($qrybook33)){
												?>
												<option value="<?php echo $rowbook33['id']; ?>"><?php echo $rowbook33['name']; ?></option>
												<?php } ?>
											</select>
										</div>
										<div class="form-group">
											<label for="exampleInputFile">فایل کلیپ تصویری</label> <input
												type="file" name="videoFile" id="exampleInputFile" required>
											<p class="help-block"></p>
										</div>
										
										<button type="submit" class="btn btn-primary">تایید و اضافه</button>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
			<div class="panel panel-default">
				<div class="panel-heading">
					<h4 class="panel-title">
						<a data-toggle="collapse" data-parent="#accordion"
							href="#collapseFour"> نویسنده - سخنران </a>
					</h4>
				</div>
				<div id="collapseFour" class="panel-collapse collapse">
					<div class="panel-body">
						<div class="row">
							<div class="col-lg-6">
								<div class="well">
									<h2>لست علما</h2>
									<table class="table">
									<tr style="background: gray;"><td>#</td><td>اسم</td><td>حذف</td></tr>
									<?php 
										$qry1=mysql_query("SELECT * FROM scholars");
										if(!$qry1){ echo "VERY BADDDDDD"; }
										$count1=1;
										while($row1=mysql_fetch_array($qry1)){
									?>
									<tr><td><?php echo $count1; ?></td><td><?php echo $row1['name']; ?></td><td><a href="execute/a_del.php?id=<?php echo $row1['id']; ?>">حذف</a></td></tr>
									<?php } ?>
									</table>
								</div>
							</div>
							<div class="col-lg-6">
								<div class="well">
									<h2>اضافه عالم جدید</h2>
									<form role="form">
										<div class="form-group">
											<label for="exampleInputEmail1">اسم</label> <input
												type="text" class="form-control" id="scholarName"
												placeholder="اسم" required>
										</div>
										<div class="form-group">
											<label for="exampleInputPassword1">توضیحات</label>
											<textarea class="form-control" id="scholarDisc" rows="5"></textarea>
										</div>
										<!-- <div class="form-group">
											<label for="exampleInputFile">تصویر</label> <input
												type="file" name="image" id="exampleInputFile" required>
											<p class="help-block"></p>
										</div>  -->
										<button onClick="add_scholar();" class="btn btn-primary">تایید و اضافه</button>
									</form>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

		</div>
	</div>

	<footer>
		<hr>
		<div class="row">
			<div class="col-lg-12">
				<p>Copyright &copy; Company 2013 &middot; Facebook &middot; Twitter
					&middot; Google+</p>
			</div>
		</div>
	</footer>


	<!-- Bootstrap core JavaScript -->
	<!-- Placed at the end of the document so the pages load faster -->
	<!-- Make sure to add jQuery - download the most recent version at http://jquery.com/ -->
	<script src="../assets/js/jquery.js"></script>
	<script src="../assets/js/bootstrap.js"></script>
	<script src="scripts.js"></script>
</body>
</html>